package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.AreaPlatform;
import com.wuseguang.springcloud.service.HaiweidaSynLogService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 海威达数据同步日志 前端控制器
 * </p>
 *
 * @author
 * @since 2020-10-29
 */
@RestController
@RequestMapping("/admin")
public class HaiweidaSynLogController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private HaiweidaSynLogService haiweidaSynLogServiceImpl;

    /**
     * 海威达同步结果
     *
     * @param uuid
     * @param logUrl
     * @return
     */
    @RequestMapping("/inserthaiweidaSynLog")
    public Result inserthaiweidaSynLog(@RequestParam(value = "uuid") String uuid,
                                       @RequestParam(value = "logUrl",required = false) String logUrl,
                                       @RequestParam(value = "logSuccessUrl",required = false) String logSuccessUrl) {
        logger.info("海威达同步结果");
        return haiweidaSynLogServiceImpl.inserthaiweidaSynLog(uuid, logUrl,logSuccessUrl);
    }

    /**
     * 根据学校id查询同步记录
     *
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findhaiweidaSynLog")
    public Result findhaiweidaSynLog(RequestParameterWrapper request, @RequestParam(value = "schoolId") String schoolId,
                                     @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                     @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows) {
        logger.info("根据学校id查询同步记录");
        return haiweidaSynLogServiceImpl.findhaiweidaSynLog(schoolId, indexNo, rows);
    }

    /**
     * 根据学校id进出校日志
     *
     * @param request
     * @param schoolId 学校id
     * @return
     */
    @RequestMapping("/findhaiweidaLog")
    public Result findhaiweidaLog(RequestParameterWrapper request, @RequestParam(value = "schoolId") String schoolId,
                                  @RequestParam(value = "startTime", required = false) String startTime,
                                  @RequestParam(value = "endTime", required = false) String endTime,
                                  @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                  @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows) {
        logger.info("根据学校id进出校日志");
        return haiweidaSynLogServiceImpl.findhaiweidaLog(schoolId,startTime,endTime, indexNo, rows);
    }

}

